package com.tedu.api.thread;


import org.junit.Test;

import java.io.File;
import java.io.FileFilter;
import java.util.ArrayList;
import java.util.List;
import java.util.function.Consumer;

public class LambdaHomeWork1 {
    public static void main(String[] args) {
        Thread t1 = new Thread(() -> {
            for (int i = 0; i < 1000; i++) {
                System.out.println("One楞One楞");
            }
        });
        t1.start();


        Runnable r=() -> {
            for (int i = 0; i < 1000; i++) {
                System.out.println("Runnable匿名内部类写法");
        }};
        Thread t2=new Thread(r);
        t2.start();


        Runnable r1=() -> {
            for (int i = 0; i < 1000; i++) {
                System.out.println("一屋两人三餐四季");
            }};
        Thread t3=new Thread(r1);
        t3.start();

    }
    @Test
    public void test1() {
        List<String> list = new ArrayList<>();
        list.add("阿西吧");
        list.add("搜都寺内");
        list.add("哟西");
        list.forEach(new Consumer<String>() {
            public void accept(String s) {
                System.out.println("排序后集合：" + list);
            }
        });

    }
    @Test
    public void test2(){
        File file=new File("."+File.separator+"API");
        /*FileFilter my=new FileFilter() {
            public boolean accept(File pathname) {
                String name=pathname.getName();
                System.out.println("过滤出来文件夹名字是："+name);
                return pathname.getName() .startsWith("s");
            }};*/

        File[] subs=file.listFiles(pathname -> {return pathname.getName().startsWith("s" );});
        /*for(int i=0;i<subs.length;i++){
            System.out.println("所有文件和文件夹名："+subs[i].getName());
        }*/
        //增强for---改成2行
        for(File f:new File("."+File.separator+"API").listFiles(pathname -> {return pathname.getName().startsWith("s" );}))
            System.out.println("所有文件和文件夹名："+f);
        }
    }






